package com.shop2cn.iapi.sqpayment.testcase;

import java.math.BigDecimal;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.shop2cn.iapi.sqpayment.parameter.RegFqlMemberWxAppBean;
import com.shop2cn.iapi.sqpayment.service.RegFqlMemberWxAppCall;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.business.service.SQPayGateWayCallService;
import com.ymttest.database.model.FqlMember;
import com.ymttest.database.model.FqlMemberExample;
import com.ymttest.database.sqlwapper.SQPayGateWayWapper;
/**
*分期乐会员注册
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_RegFqlMemberWxApp{
	private static RegFqlMemberWxAppBean RegFqlMemberWxAppBean;
	private static RegFqlMemberWxAppCall RegFqlMemberWxAppCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("分期乐会员注册");
	}

	@Before
	public void caseUp() {
		RegFqlMemberWxAppBean=new RegFqlMemberWxAppBean();
		RegFqlMemberWxAppCall=new RegFqlMemberWxAppCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(RegFqlMemberWxAppCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	//用户已经切换到线上-SIT不支持支付了
	public void Tc_RegFqlMemberWxApp_001() {
		Logger.start(true,"分期乐会员注册成功-有手机号");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token=registerResult.get("Token").getAsString();
			int uid  = urrc.getUserid();
			RegFqlMemberWxAppBean.setUserId(uid);
			RegFqlMemberWxAppCall.setData(RegFqlMemberWxAppBean);
			RegFqlMemberWxAppCall.callService();			
			Logger.verifyEquals("0", RegFqlMemberWxAppCall.getString("ErrorCode"), "验证ErrorCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RegFqlMemberWxApp_002() {
		Logger.start(true,"不输入userid失败");
		try {
			RegFqlMemberWxAppCall.setData(RegFqlMemberWxAppBean);
			RegFqlMemberWxAppCall.callService();			
			Logger.verifyEquals("1000", RegFqlMemberWxAppCall.getString("ErrorCode"), "验证ErrorCode");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RegFqlMemberWxApp_003() {
		Logger.start(true,"输入不存在userid失败");
		try {
			RegFqlMemberWxAppBean.setUserId(-99999);
			RegFqlMemberWxAppCall.setData(RegFqlMemberWxAppBean);
			RegFqlMemberWxAppCall.callService();			
			Logger.verifyEquals("1000", RegFqlMemberWxAppCall.getString("ErrorCode"), "验证ErrorCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	//用户已经切换到线上-SIT不支持支付了
	public void Tc_RegFqlMemberWxApp_004() {
		Logger.start(true,"分期乐会员注册用户无手机号");
		try {
			RegFqlMemberWxAppBean.setUserId(92);
			RegFqlMemberWxAppCall.setData(RegFqlMemberWxAppBean);
			RegFqlMemberWxAppCall.callService();			
			Logger.verifyEquals("0", RegFqlMemberWxAppCall.getString("ErrorCode"), "验证ErrorCode");
			String PaymentUrl = RegFqlMemberWxAppCall.getJsonObject().get("PaymentUrl").getAsString();
			Logger.verifyIsContains("sale.fenqile.com", PaymentUrl, "验证url");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
//	@Ignore
	//用户已经切换到线上-SIT不支持支付了
	public void Tc_RegFqlMemberWxApp_005() {
		Logger.start(true,"分期乐会员注册用户带FqlToken");
		try {
			RegFqlMemberWxAppBean.setUserId(200);
			RegFqlMemberWxAppBean.setFqlToken("token22");
			RegFqlMemberWxAppCall.setData(RegFqlMemberWxAppBean);
			RegFqlMemberWxAppCall.callService();			
			Logger.verifyEquals("0", RegFqlMemberWxAppCall.getString("ErrorCode"), "验证ErrorCode");
			String PaymentUrl = RegFqlMemberWxAppCall.getJsonObject().get("PaymentUrl").getAsString();
			Logger.verifyIsContains("fenqile.com", PaymentUrl, "验证url");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}